/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.woupla.model;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlRootElement;

/**
 * 
 * @author dimi
 */
@Entity
@Table(name = "rdv")
@XmlRootElement
@NamedQueries({
		@NamedQuery(name = "Rdv.findAll", query = "SELECT r FROM Rdv r"),
		@NamedQuery(name = "Rdv.findById", query = "SELECT r FROM Rdv r WHERE r.id = :id"),
		@NamedQuery(name = "Rdv.findAllForUser", query = "SELECT r FROM Rdv r WHERE r.user = :userId"),
		@NamedQuery(name = "Rdv.countForUser", query = "SELECT count(r) FROM Rdv r WHERE r.user = :userId"),
		@NamedQuery(name = "Rdv.findByDateDebut", query = "SELECT r FROM Rdv r WHERE r.dateDebut = :dateDebut"),
		@NamedQuery(name = "Rdv.findByDateFin", query = "SELECT r FROM Rdv r WHERE r.dateFin = :dateFin"),
		@NamedQuery(name = "Rdv.findByConfirme", query = "SELECT r FROM Rdv r WHERE r.confirme = :confirme") })
public class Rdv implements Serializable {
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Basic(optional = false)
	@Column(name = "id")
	private Integer id;
	@Column(name = "confirme")
	private Integer confirme;
	@Column(name = "dateDebut")
	@Temporal(TemporalType.TIMESTAMP)
	private Date dateDebut;
	@Column(name = "dateFin")
	@Temporal(TemporalType.TIMESTAMP)
	private Date dateFin;
	@Basic(optional = false)
	@Column(name = "employee")
	private User employee;
	@Basic(optional = false)
	@Column(name = "user")
	private User user;
	@JoinColumns({
			@JoinColumn(name = "produit_gen", referencedColumnName = "produit"),
			@JoinColumn(name = "produit", referencedColumnName = "id"),
			@JoinColumn(name = "company", referencedColumnName = "Company") })
	@ManyToOne(optional = false)
	private Companyproduit companyproduit;

	public Rdv() {
	}

	public Rdv(Integer id) {
		this.id = id;
	}

	public Rdv(Integer id, User employee, User user) {
		this.id = id;
		this.employee = employee;
		this.user = user;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public Integer getConfirme() {
		return confirme;
	}

	public void setConfirme(Integer confirme) {
		this.confirme = confirme;
	}

	public Date getDateDebut() {
		return dateDebut;
	}

	public void setDateDebut(Date dateDebut) {
		this.dateDebut = dateDebut;
	}

	public Date getDateFin() {
		return dateFin;
	}

	public void setDateFin(Date dateFin) {
		this.dateFin = dateFin;
	}

	public User getEmployee() {
		return employee;
	}

	public void setEmployee(User employee2) {
		this.employee = employee2;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public Companyproduit getCompanyproduit() {
		return companyproduit;
	}

	public void setCompanyproduit(Companyproduit companyproduit) {
		this.companyproduit = companyproduit;
	}

	@Override
	public int hashCode() {
		int hash = 0;
		hash += (id != null ? id.hashCode() : 0);
		return hash;
	}

	@Override
	public boolean equals(Object object) {
		// TODO: Warning - this method won't work in the case the id fields are
		// not set
		if (!(object instanceof Rdv)) {
			return false;
		}
		Rdv other = (Rdv) object;
		if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
			return false;
		}
		return true;
	}

	@Override
	public String toString() {
		return "javaapplication1.Rdv[ id=" + id + " ]";
	}

}
